﻿// 有关“页面控制”模板的简介，请参阅以下文档:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function () {
    "use strict";

    WinJS.UI.Pages.define("/pages/pictureDetail/pictureDetail.html", {
        // 每当用户导航至此页面时都要调用此功能。它
        // 使用应用程序的数据填充页面元素。
        ready: function (element, options) {
            var item = options;
            var classes = encodeURIComponent(item.classes);
            var id = encodeURIComponent(item.id);
            var dataUrl = 'http://app.hbook.us/flashinterface/GetPicturesDetails.ashx?picID=' + id;
            var relatedDataUrl = 'http://app.hbook.us/flashinterface/GetPicturesByPage.ashx?page=1&pagesize=1000&topicid=5&classes=' + classes;
            var relatedData = page.fun.getPictureDataList(relatedDataUrl);
            var pictureData = page.fun.getPictureDetailDataList(dataUrl);

            page.fun.bindDate(
                {
                    dataType: "picture",
                    element: element,
                    dataList: relatedData,
                    listviewID: "#picture-related",
                    listTemplate: "#listTemplatePicture",
                    LayoutType: "ListLayout"
                }
            );
            element.querySelector(".picture-t").textContent = item.title;

            page.fun.bindFlipViewDate(
                {
                    element: element,
                    dataList: pictureData,
                    listviewID: "#pictureFlipView",
                    listTemplate: "#FlipViewTemplate",
                    LayoutType: "ListLayout"
                }
            );


        },

        unload: function () {
            // TODO: 响应导航到其他页。
        },

        updateLayout: function (element, viewState, lastViewState) {
            /// <param name="element" domElement="true" />

            // TODO: 响应 viewState 的更改。
        }
    });
})();
